{% extends 'base.html' %}

{% block title %}删除用户 - 固定资产管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{% url 'assets:index' %}">首页</a></li>
                <li class="breadcrumb-item"><a href="{% url 'assets:user_list' %}">用户管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">删除用户</li>
            </ol>
        </nav>
        
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card border-danger">
                    <div class="card-header bg-danger text-white">
                        <h5 class="mb-0">
                            <i class="fas fa-exclamation-triangle me-2"></i>确认删除用户
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="alert alert-warning">
                            <i class="fas fa-warning me-2"></i>
                            <strong>警告：</strong>此操作不可撤销！删除用户后，该用户的所有数据和权限将被永久删除。
                        </div>
                        
                        <div class="mb-4">
                            <h6>即将删除的用户信息：</h6>
                            <div class="card bg-light">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <p><strong>用户名：</strong>{{ user_obj.username }}</p>
                                            <p><strong>姓名：</strong>
                                                {% if user_obj.first_name or user_obj.last_name %}
                                                    {{ user_obj.first_name }} {{ user_obj.last_name }}
                                                {% else %}
                                                    <span class="text-muted">未设置</span>
                                                {% endif %}
                                            </p>
                                        </div>
                                        <div class="col-md-6">
                                            <p><strong>邮箱：</strong>
                                                {% if user_obj.email %}
                                                    {{ user_obj.email }}
                                                {% else %}
                                                    <span class="text-muted">未设置</span>
                                                {% endif %}
                                            </p>
                                            <p><strong>注册时间：</strong>{{ user_obj.date_joined|date:"Y-m-d H:i" }}</p>
                                        </div>
                                    </div>
                                    
                                    <div class="row">
                                        <div class="col-12">
                                            <p><strong>权限：</strong>
                                                {% if user_obj.is_superuser %}
                                                    <span class="badge bg-danger me-1">超级用户</span>
                                                {% endif %}
                                                {% if user_obj.is_staff %}
                                                    <span class="badge bg-info me-1">员工</span>
                                                {% endif %}
                                                {% if not user_obj.is_active %}
                                                    <span class="badge bg-secondary me-1">未激活</span>
                                                {% endif %}
                                            </p>
                                            
                                            {% if user_obj.groups.exists %}
                                            <p><strong>用户组：</strong>
                                                {% for group in user_obj.groups.all %}
                                                    <span class="badge bg-primary me-1">{{ group.name }}</span>
                                                {% endfor %}
                                            </p>
                                            {% endif %}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="d-flex justify-content-between">
                            <a href="{% url 'assets:user_list' %}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left me-1"></i>取消
                            </a>
                            <form method="post" class="d-inline">
                                {% csrf_token %}
                                <button type="submit" class="btn btn-danger" onclick="return confirm('您确定要删除用户 {{ user_obj.username }} 吗？此操作不可撤销！')">
                                    <i class="fas fa-trash me-1"></i>确认删除
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}